package test.zhuwei
{
	import _Pan3D.core.MathCore;
	import _Pan3D.display3D.Display3DContainer;
	import _Pan3D.display3D.Display3DSprite;
	import _Pan3D.program.Program3DManager;
	
	import _me.Scene_data;
	
	import flash.display3D.Context3D;
	import flash.display3D.Program3D;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import test.vo.StatVO;
	import test.vo.TreeShader;
	import test.vo.uvMove.Display3DUvMove;
	import test.vo.uvMove.UvMoveShader;
	
	public class TiexiaoDisply
	{
		private var _context3D:Context3D;
		private var _groundDisplay3DContainer:Display3DContainer;
		private var _loaderURL:URLRequest;
		private var _scenexml:URLLoader;
		private var _groundItem:Array;
		public function TiexiaoDisply(tempContext3D:Context3D,tempContainer:Display3DContainer):void
		{
			_context3D=tempContext3D;
			_groundDisplay3DContainer=tempContainer;
			_loaderURL = new URLRequest(Scene_data.fileRoot+"uvList.xml");
			_scenexml=new URLLoader();
			_scenexml.load(_loaderURL);
			_scenexml.addEventListener(Event.COMPLETE, _loadGroundXmlOk);
			
		}
		private function _loadGroundXmlOk(evt:Event):void
		{
			var _item:Array =MathCore.getSourcePro(XML(_scenexml.data));
			_groundItem=new Array;
			for(var  i:int=0;i<_item.length;i++){
				var statVO:StatVO=new StatVO;
				statVO.et=_item[i].et;
				statVO.scale=_item[i].scale;
				statVO.x=_item[i].x;
				statVO.y=_item[i].y;
				statVO.z=_item[i].z;
				statVO.type=_item[i].type;
				
				statVO.name=_item[i].name;
				_groundItem.push(statVO);
				
			
			}
			for(var j:int=0;j<_groundItem.length;j++){
				var tempVo:StatVO=_groundItem[j] as StatVO;
				var display3DSprite:Display3DUvMove =new Display3DUvMove(_context3D);
				display3DSprite.url =tempVo.et
				display3DSprite.x=tempVo.x;
				display3DSprite.y=tempVo.y;
				display3DSprite.z=tempVo.z;
				display3DSprite.scale=tempVo.scale
				_groundDisplay3DContainer.addChild(display3DSprite);
				
			}
			var treeShaderProgram3d:Program3D =  Program3DManager.getInstance().getProgram(UvMoveShader.UVMOVE_SHADER);
			_groundDisplay3DContainer.setProgram3D(treeShaderProgram3d);
			
		}
	}
}